# Copyright 2007 Marco Cesati <cesati@uniroma2.it>

FILENAME=df
SOURCEFILE=main
BIBFILE=refs.bib
DATE:=$(shell date +%Y%m%d%H%M%S)
TEXFILES:=$(shell ls *.tex)

TARGETS=$(FILENAME:%=%.pdf)

all: $(TARGETS)
	@grep FIXME $(SOURCEFILE).log || true
	@pdftotext $(FILENAME).pdf - | wc -w

%.bbl: %.tex $(BIBFILE)
	pdflatex $(SOURCEFILE)
	bibtex $(SOURCEFILE)

$(FILENAME).pdf: $(SOURCEFILE).pdf
	pdfopt $^ $(FILENAME:%=%.pdf)

%.pdf: %.bbl $(TEXFILES)
	./latexcompile $* $(DATE)

clean:
	rm -f *~ *.{dvi,aux,log,out,blg,bbl,bak} $(TARGETS) $(FILENAME:%=%.pdf) $(SOURCEFILE:%=%.pdf)

.PRECIOUS: %.bbl %.pdf
.PHONY: clean pdf 
.SILENT: clean
